﻿using System;
using System.Configuration;

namespace CodePlex.TfsPluginSuite.Configuration.BranchMergePolicy
{
    [ConfigurationCollection(typeof(TargetPathConfigurationElement), AddItemName = "TargetPath", CollectionType = ConfigurationElementCollectionType.BasicMapAlternate)]
    public class SourcePathConfigurationElement : ConfigurationElementCollection
    {
        [ConfigurationProperty("pathRegex", IsRequired = true)]
        public string PathRegex
        {
            get
            {
                return (string)base["pathRegex"];
            }
        }

        [ConfigurationProperty("unrestricted", DefaultValue = (bool)false)]
        public bool IsUnrestricted
        {
            get
            {
                return (bool)base["unrestricted"];
            }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new TargetPathConfigurationElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            return ((TargetPathConfigurationElement)element).PathRegex;
        }
    }
}
